import Router from 'koa-router';
import proxyService from '../../../common/proxyService';
import {
  saveGroupPurchaseData,
  modifyGroupPurchaseData,
  getGroupBuyInfo, // 拼团活动详情
  getGroupBuyList, // 获取消息列表
  updateGroupBuyStatus, // 拼团活动上下架
  deleteSpellGroup, // 删除拼团活动
} from '../../../api/groupPurchase';

const router = new Router();

//
router.post('/saveData', async ctx => {
  const response = await proxyService.postProxy(ctx, saveGroupPurchaseData);
  return (ctx.body = response);
});

//
router.post('/modifyData', async ctx => {
  const response = await proxyService.postProxy(ctx, modifyGroupPurchaseData);
  return (ctx.body = response);
});
// 拼团活动详细
router.get('/getGroupBuyInfo', async ctx => {
  const response = await proxyService.postProxy(ctx, getGroupBuyInfo);
  return (ctx.body = response);
});

// 获取拼团列表
router.post('/getGroupBuyList', async ctx => {
  const response = await proxyService.postProxy(ctx, getGroupBuyList);
  return (ctx.body = response);
});

// 拼团活动上下架
router.post('/updateGroupBuyStatus', async ctx => {
  const response = await proxyService.postProxy(ctx, updateGroupBuyStatus);
  return (ctx.body = response);
});

// 删除拼团活动
router.post('/deleteSpellGroup', async ctx => {
  const response = await proxyService.postProxy(ctx, deleteSpellGroup);
  return (ctx.body = response);
});

export default router;
